package com.sam.jifenbao;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

/**
 * Created by Administrator on 2016/6/7.
 */
public class UserCenterActivity extends BaseHeaderActivity {

    private EditText phoneNumET,birthdayET;
    private ImageView pencilBtn,addBtn;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_center);
        findView();
        initView();
    }

    @Override
    protected void findView() {
        phoneNumET = (EditText) findViewById(R.id.write_phont_num_et);
        birthdayET = (EditText) findViewById(R.id.write_birthday_et);
        pencilBtn = (ImageView) findViewById(R.id.icon_pencil);
        addBtn = (ImageView) findViewById(R.id.icon_add);
    }

    @Override
    protected void initView() {
        getHeaderView().setTitleText(R.string.user_center);
        phoneNumET.setEnabled(false);
        birthdayET.setEnabled(false);
        pencilBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                phoneNumET.setEnabled(true);
                phoneNumET.requestFocus();
            }
        });
        addBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                birthdayET.setEnabled(true);
                birthdayET.requestFocus();
            }
        });

        phoneNumET.setOnFocusChangeListener(onFocusChangeListener);
        birthdayET.setOnFocusChangeListener(onFocusChangeListener);
    }

    private View.OnFocusChangeListener onFocusChangeListener = new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            switch (v.getId()){
                case R.id.write_phont_num_et:
                    phoneNumET.setEnabled(hasFocus);
                break;

                case R.id.write_birthday_et:
                    birthdayET.setEnabled(hasFocus);
                break;
            }
        }
    };
}
